{% extends "base.html" %}

{% block title %}PSES Calculations{% endblock %}

{% block scripts %}
<script>
function reduce_choices(val)
{
var x=document.getElementById("id_bptypeid");
var y=document.getElementById("excluded");
var patt = new RegExp(val, "i");
var option=document.createElement("option");
var txt = "";
var len=x.length;
var len2=y.length;
var i, j;
var t, s;
for (i=0;i<len;i++)
  {
  t=len-i-1;
  if ( !patt.test(x.options[t].text) )
    {
    option=document.createElement("option");
    option.text=x.options[t].text;
    option.value=x.options[t].value;
    y.add(option, null);
    x.remove(t);
    }
  }
for (j=0;j<len2;j++)
  {
  s=len2-j-1;
  if ( patt.test(y.options[s].text) )
    {
    option=document.createElement("option");
    option.text=y.options[s].text;
    option.value=y.options[s].value;
    x.add(option, null);
    y.remove(s);
    }
  }
}
function addrow()
{
var z = document.getElementById("myform");
var element = document.createElement("select");
    element.setAttribute("name","deux");

z.appendChild(element);
}
</script>
{% endblock %}

{% block app %}PSES Calculations: Shopping list{% endblock %}

{% block content %}
<form id="myform" action="{% url "eve_scm.views.basket" %}" method="post">{% csrf_token %}
Search : <input type="text" oninput="reduce_choices(this.value)">
{{ form.as_p }}
<button type="button" onclick="addrow()">add</button>
<input type="submit" value="submit" />
<select id="excluded" style="visibility:hidden;"></select>
</form>
{% endblock %}